//
//  Test17.cpp
//  CPPTest
//
//  Created by you5 Yi on 2021/9/25.
//

#include "Test17.hpp"
#include <iostream>
#include <math.h>
using namespace std;

class point {
private:
    float x, y;
public:
    point(float a, float b) {
        x = a;
        y = b;
    }
    point() {
        x = 0;
        y = 0;
    }
    void set(float a, float b) {
        x = a;
        y = b;
    }
    float getx() {
        return x;
    }
    float gety() {
        return y;
    }
};

class tri {
    point x, y, z;
    float s1, s2, s3;
public:
    void settri(float x1, float y1, float x2, float y2, float x3, float y3);
    void test();
};

void tri::settri(float x1, float y1, float x2, float y2, float x3, float y3)
{
    x.set(x1, y1);
    y.set(x2, y2);
    z.set(x3, y3);
}

void tri::test()
{
    float sum1, sum2, sum3;
    s1 = sqrt((x.getx()-y.getx())*(x.getx()-y.getx())+(x.gety()-y.gety())*(x.gety()-y.gety()));
    s2 = sqrt((x.getx()-z.getx())*(x.getx()-z.getx())+(x.gety()-z.gety())*(x.gety()-z.gety()));
    s3 = sqrt((y.getx()-z.getx())*(y.getx()-z.getx())+(y.gety()-z.gety())*(y.gety()-z.gety()));
    
    sum1 = s1 + s2;
    sum2 = s1 + s3;
    sum3 = s2 + s3;
    
    if (sum1 > s3 && sum2 > s2 && sum3 > s1) {
        cout<<"可以成为三角形"<<endl;
    } else {
        cout<<"不能成为三角形"<<endl;
    }
}

void test17() {
    tri triobj;
    triobj.settri(0, 0, 0, 1, 0, 2);
    triobj.test();
}
